set mem 500m
set more off
cap cd "C:\Users\ejm5\Dropbox\Rents_Asunder\AJPS_ReplicationFiles\data"
cap cd "/Users/dimitargueorguiev/Dropbox/Rents_Asunder/AJPS_ReplicationFiles/data/"
use 20140308_money_d1.dta, clear

cap cd "C:\Users\ejm5\Dropbox\Rents_Asunder\AJPS_ReplicationFiles\output"
cap cd "/Users/dimitargueorguiev/Dropbox/Rents_Asunder/AJPS_ReplicationFiles/output/"

/***************************************************************Table 1************************************************/
log using table1.smcl, replace
#delimit cr
set more off
mean reg_corrupt if reg_year>=2000, over(FDI restrict treatment)
mean reg_corrupt if reg_year>=2000, over(FDI restrict_all treatment)
log close

/***************************************************************Appendix 6************************************************/

log using appendix6.smcl, replace
dprobit restrict equity_est labor_est university MBA connection_dich if FDI==0, cluster(pci_id)
outreg2 using restricted_firms,  bdec(3) tdec(3) e(all) replace excel
dprobit restrict equity_est labor_est university MBA connection_gov connection_mil connection_soe_e if FDI==0, cluster(pci_id)
outreg2 using restricted_firms,  bdec(3) tdec(3) e(all) excel
log close


/******************************************************Table 2*******************************************************/
set more off
log using table2.smcl, replace


/*Model 1: Replicate IMAI LIST ESTIMATOR ----*/
reg reg_corrupt treatment if reg_year>=2000, cluster(pci_id) robust
outreg2 using rents_OLS, bdec(3) tdec(3) e(all) replace
xi: nbreg reg_corrupt if treatment==0 & reg_year>=2000, robust cluster(pci_id)
outreg2 using rents_1ststage, bdec(3) tdec(3) e(all) replace
predict ns_items
generate bribe=reg_corrupt-ns_items
nl (bribe = {b0}) if treatment==1 & reg_year>=2000, cluster(pci_id) vce(bootstrap, reps(1000)) 
estat ic
estimates store T2_Model1  
outreg2 using rents_2ndstage,  bdec(3) tdec(3) e(all) replace
drop ns_items bribe

/*Model 2: Survey Year Fixed Effects*/
set more off
xi: reg reg_corrupt i.treatment*y2011 i.treatment*y2012 if reg_year>=2000 , cluster(pci_id) robust
outreg2 using rents_OLS, bdec(3) tdec(3) e(all) 
xi: nbreg reg_corrupt y2011 y2012 if treatment==0 & reg_year>=2000, robust cluster(pci_id)
outreg2 using rents_1ststage, bdec(3) tdec(3) e(all) 
predict ns_items
generate bribe=reg_corrupt-ns_items
nl (bribe = {b0}+{b1}*y2011+{b2}*y2012) if treatment==1 & reg_year>=2000, cluster(pci_id) vce(bootstrap, reps(1000))   variables(y2011 y2012)
estat ic
estimates store T2_Model2
mfx
outreg2 using rents_2ndstage, mfx bdec(3) tdec(3) e(all) 
drop ns_items bribe

/*Model 3: No Controls*/
xi: nbreg reg_corrupt FDI restrict  FDI_res   if treatment==0 & reg_year>=2000, robust cluster(pci_id)
outreg2 using rents_1ststage, bdec(3) tdec(3) e(all) 
predict ns_items
generate bribe=reg_corrupt-ns_items
nl (bribe = {b0}+{b1}*FDI+{b2}*restrict+{b3}*FDI_res) if treatment==1 & reg_year>=2000, cluster(pci_id) vce(bootstrap, reps(1000))    variables (FDI restrict  FDI_res )
estat ic
estimates store T2_Model3
mfx
outreg2 using rents_2ndstage, mfx bdec(3) tdec(3) e(all) 
drop ns_items bribe

/*LINCOM*/
lincom  _b[b0:_cons]+_b[b1:_cons]*0+_b[b2:_cons]*0+_b[b3:_cons]*0, level(90)
lincom  _b[b0:_cons]+_b[b1:_cons]*0+_b[b2:_cons]*1+_b[b3:_cons]*0, level(90)
lincom  _b[b0:_cons]+_b[b1:_cons]*1+_b[b2:_cons]*0+_b[b3:_cons]*0, level(90)
lincom  _b[b0:_cons]+_b[b1:_cons]*1+_b[b2:_cons]*1+_b[b3:_cons]*1, level(90)

/*Counterfactual*/
display [( .1655844*2814)+(.2837969*517)]/3331
display [( .1655844*2814)+(.1655844*517)]/3331
display [( .2837969*2814)+(.2837969*517)]/3331


/*Model 4: No Controls Year FE*/
xi: nbreg reg_corrupt FDI restrict  FDI_res y2011 y2012   if treatment==0 & reg_year>=2000, robust cluster(pci_id)
outreg2 using rents_1ststage, bdec(3) tdec(3) e(all) 
predict ns_items
generate bribe=reg_corrupt-ns_items
nl (bribe = {b0}+{b1}*FDI+{b2}*restrict+{b3}*FDI_res+{b4}*y2011+{b5}*y2012) if treatment==1 & reg_year>=2000, cluster(pci_id) vce(bootstrap, reps(1000))    variables (y2011 y2012 FDI restrict  FDI_res )
estat ic
estimates store T2_Model4
mfx
outreg2 using rents_2ndstage, mfx bdec(3) tdec(3) e(all) 
drop ns_items bribe



/*Model 5: Size*/
xi: nbreg reg_corrupt FDI restrict  FDI_res equity_est y2011 y2012   if treatment==0 & reg_year>=2000, robust cluster(pci_id)
outreg2 using rents_1ststage, bdec(3) tdec(3) e(all) 
predict ns_items
generate bribe=reg_corrupt-ns_items
nl (bribe = {b0}+{b1}*FDI+{b2}*restrict+{b3}*FDI_res+{b4}*equity_est+{b5}*y2011+{b6}*y2012) if treatment==1 & reg_year>=2000, cluster(pci_id) vce(bootstrap, reps(1000))    variables (y2011 y2012 FDI restrict  FDI_res  equity_est)
estat ic
estimates store T2_Model5
mfx
outreg2 using rents_2ndstage, mfx bdec(3) tdec(3) e(all) 
drop ns_items bribe


/*Model 6. Time Trend*/
xi: nbreg reg_corrupt FDI restrict  FDI_res equity_est y2011 y2012 time time_sq   if treatment==0 & reg_year>=2000, robust cluster(pci_id)
outreg2 using rents_1ststage, bdec(3) tdec(3) e(all) 
predict ns_items
generate bribe=reg_corrupt-ns_items
nl (bribe = {b0}+{b1}*FDI+{b2}*restrict+{b3}*FDI_res+{b4}*equity_est+{b5}*y2011+{b6}*y2012+{b7}*time+{b8}*time_sq) if treatment==1 & reg_year>=2000, cluster(pci_id) vce(bootstrap, reps(1000))    variables (y2011 y2012 FDI restrict  FDI_res  equity_est time time_sq)
estat ic
estimates store T2_Model6
mfx
outreg2 using rents_2ndstage, mfx bdec(3) tdec(3) e(all) 
drop ns_items bribe


/*Model 7: Fully-Specified SOE Connections*/
xi: nbreg reg_corrupt y2011 y2012 FDI restrict equity_est FDI_res time time_sq connection_soe expand if treatment==0 & reg_year>=2000, robust cluster(pci_id)
outreg2 using rents_1ststage, bdec(3) tdec(3) e(all) 
predict ns_items
generate bribe=reg_corrupt-ns_items
nl (bribe = {b0}+{b1}*y2011+{b2}*y2012 +{b3}*FDI+{b4}*restrict+{b5}*equity_est+{b6}*FDI_res+{b7}*time+{b8}*time_sq+{b9}*connection_soe+{b10}*expand) if treatment==1 & reg_year>=2000, cluster(pci_id) vce(bootstrap, reps(1000))    variables (y2011 y2012 FDI restrict equity_est FDI_res time time_sq connection_soe expand)
mfx
estat ic
estimates store T2_Model7
outreg2 using rents_2ndstage, mfx bdec(3) tdec(3) e(all) 
drop ns_items bribe



/*Lincom Marginal Effects*/
lincom  _b[b0:_cons]+_b[b3:_cons]*0+_b[b4:_cons]*0+_b[b6:_cons]*0, level(90)
lincom  _b[b0:_cons]+_b[b3:_cons]*1+_b[b4:_cons]*0+_b[b6:_cons]*0, level(90)
lincom  _b[b0:_cons]+_b[b3:_cons]*0+_b[b4:_cons]*1+_b[b6:_cons]*0, level(90)
lincom  _b[b0:_cons]+_b[b3:_cons]*1+_b[b4:_cons]*1+_b[b6:_cons]*1, level(90)
lincom  (_b[b3:_cons]*1+_b[b4:_cons]*1+_b[b6:_cons]*1)- (_b[b3:_cons]*1+_b[b4:_cons]*0+_b[b6:_cons]*0), level(90)
lincom  (_b[b3:_cons]*1+_b[b4:_cons]*1+_b[b6:_cons]*1)- (_b[b3:_cons]*0+_b[b4:_cons]*1+_b[b6:_cons]*0), level(90)

display [(.2447096*2814)+(.2447096*517)]/3331
display [(.2447096*2814)+(.4553935*517)]/3331


/*****************************************************Sector Fixed Effects******************************************/

set matsize 900


/*Model 8:  Sector Fixed Effects*/
xi: areg reg_corrupt y2011 y2012 FDI restrict FDI_res  equity_est  time time_sq connection_soe expand  if treatment==0 & reg_year>=2000, robust absorb(isic_rev4_2) cluster(pci_id)
outreg2 using rents_FE, bdec(3) tdec(3) e(all) 
predict ns_items
generate bribe=reg_corrupt-ns_items
xi: areg bribe y2011 y2012 FDI restrict FDI_res   equity_est  time time_sq connection_soe  expand if treatment==1 & reg_year>=2000,  absorb(isic_rev4_2)  cluster(pci_id)
estat ic
estimates store T2_Model8
outreg2 using rents_2ndstage, bdec(3) tdec(3) e(all) 
drop ns_items bribe



/***Model 9: With Restrict All*************/
xi: nbreg reg_corrupt FDI restrict_all  FDI_res_all equity_est y2011 y2012 time time_sq connection_soe  expand  if treatment==0 & reg_year>=2000, robust cluster(pci_id)
predict ns_items
generate bribe=reg_corrupt-ns_items
nl (bribe = {b0}+{b1}*FDI+{b2}*restrict_all+{b3}*FDI_res_all+{b4}*equity_est+{b5}*y2011+{b6}*y2012+{b7}*time+{b8}*time_sq+{b9}*connection_soe+{b10}*expand) if treatment==1 & reg_year>=2000, cluster(pci_id) vce(bootstrap, reps(1000))    variables (y2011 y2012 FDI restrict_all  FDI_res_all  equity_est time time_sq connection_soe expand)
estat ic
estimates store T2_Model9
mfx
outreg2 using rents_2ndstage, mfx bdec(3) tdec(3) e(all) excel
drop ns_items bribe

lincom  _b[b0:_cons]+_b[b3:_cons]*0+_b[b4:_cons]*0+_b[b6:_cons]*0, level(90)
lincom  _b[b0:_cons]+_b[b3:_cons]*1+_b[b4:_cons]*0+_b[b6:_cons]*0, level(90)
lincom  _b[b0:_cons]+_b[b3:_cons]*0+_b[b4:_cons]*1+_b[b6:_cons]*0, level(90)
lincom  _b[b0:_cons]+_b[b3:_cons]*1+_b[b4:_cons]*1+_b[b6:_cons]*1, level(90)
lincom  (_b[b3:_cons]*1+_b[b4:_cons]*1+_b[b6:_cons]*1)- (_b[b3:_cons]*1+_b[b4:_cons]*0+_b[b6:_cons]*0), level(90)
lincom  (_b[b3:_cons]*1+_b[b4:_cons]*1+_b[b6:_cons]*1)- (_b[b3:_cons]*0+_b[b4:_cons]*1+_b[b6:_cons]*0), level(90)


/*LR TESTS*/
lrtest T2_Model1 T2_Model2, stats force
lrtest T2_Model1 T2_Model3, stats force
lrtest T2_Model1 T2_Model4, stats force
lrtest T2_Model1 T2_Model5, stats force
lrtest T2_Model1 T2_Model6, stats force
lrtest T2_Model1 T2_Model7, stats force
lrtest T2_Model1 T2_Model8, stats force
lrtest T2_Model1 T2_Model9, stats force
log close

cap cd "C:\Users\ejm5\Dropbox\Rents_Asunder\AJPS_ReplicationFiles\do"
cap cd "/Users/dimitargueorguiev/Dropbox/Rents_Asunder/AJPS_ReplicationFiles/do/"
